package com.code.day10.IOStream;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

public class Demo {
    public static void main(String[] args) throws IOException {
        method();
    }
    private static void method() throws IOException {
        try{
            FileOutputStream fos = new FileOutputStream("1.txt", true);
            fos.write("我是王鑫\r\n".getBytes());
            fos.close();
        }catch (Exception e){
            System.out.println("File not found");
        }
    }
    private static void method1() throws IOException {
        try{
            FileOutputStream fos = new FileOutputStream("1.txt", false);
            byte[] bytes = {97, 98, 99, 100};
            fos.write(bytes);
            fos.close();
        }catch (Exception e){
            System.out.println("File not found");
        }
    }
    private static void method3() throws IOException {
        try{
            FileOutputStream fos = new FileOutputStream("1.txt");
            byte[] bytes = {97, 98, 99, 100};
            fos.write(bytes, 1, 3);
            fos.close();
        }catch (Exception e){
            System.out.println("File not found");
        }
    }
}

